package com.ctgu.蓝桥杯真题.B组2020第2场;

import java.io.*;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Vector;

/**
 * @author: Backdiy
 * @data: 2021/4/6 21:29
 * @desc:
 */
/*
5
7
3 8
8 1 0
2 7 4 4
4 5 2 6 5
* */
public class H数字三角形 {
    public static void main(String[] args) throws IOException {
        int n = Input.nextInt();
        int[][] arr = new int[n + 1][];
        for (int i = 1; i <= n; i++) {
            arr[i] = new int[i + 2];
            for (int j = 1; j <= i; j++) {
                arr[i][j] = Input.nextInt();
            }
        }
        for (int i = 2; i <= n; i++) {
            for (int j = 1; j <= i; j++) {
                arr[i][j] = arr[i][j] + Math.max(arr[i - 1][j - 1], arr[i - 1][j]);
            }
        }
        if ((n & 1) == 1) {
            Input.out.println(arr[n][n/2+1]);
        } else {
            Input.out.println(Math.max(arr[n][n/2],arr[n][n/2+1]));
        }
        Input.out.flush();
    }

    static class Input {
        static StreamTokenizer streamTokenizer = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        static PrintWriter out = new PrintWriter((new OutputStreamWriter(System.out)));
        static BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));

        static int nextInt() throws IOException {
            streamTokenizer.nextToken();
            return (int) streamTokenizer.nval;
        }

        static double nextDouble() throws IOException {
            streamTokenizer.nextToken();
            return streamTokenizer.nval;
        }

        static long nextLong() throws IOException {
            streamTokenizer.nextToken();
            return (long) streamTokenizer.nval;
        }

        static String nextLine() throws IOException {
            return bufferedReader.readLine();
        }

        static char next() throws IOException {
            return (char) bufferedReader.read();
        }
    }
}
